package com.ruoyi.job_users.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.common.core.domain.entity.SysUser;
import com.ruoyi.common.utils.SecurityUtils;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.job_users.domain.JobUsers;
import com.ruoyi.job_users.service.IJobUsersService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 就业信息Controller
 * 
 * @author ruoyi
 * @date 2024-11-13
 */
@RestController
@RequestMapping("/job_users/job_users")
public class JobUsersController extends BaseController
{
    @Autowired
    private IJobUsersService jobUsersService;

    /**
     * 查询就业信息列表
     */
    @PreAuthorize("@ss.hasPermi('job_users:job_users:list')")
    @GetMapping("/list")
    public TableDataInfo list(JobUsers jobUsers)
    {
        startPage();
        List<JobUsers> list = jobUsersService.selectJobUsersList(jobUsers);
        return getDataTable(list);
    }

    /**
     * 导出就业信息列表
     */
    @PreAuthorize("@ss.hasPermi('job_users:job_users:export')")
    @Log(title = "就业信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, JobUsers jobUsers)
    {
        List<JobUsers> list = jobUsersService.selectJobUsersList(jobUsers);
        ExcelUtil<JobUsers> util = new ExcelUtil<JobUsers>(JobUsers.class);
        util.exportExcel(response, list, "就业信息数据");
    }

    /**
     * 获取就业信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('job_users:job_users:query')")
    @GetMapping(value = "/{jobUserId}")
    public AjaxResult getInfo(@PathVariable("jobUserId") Long jobUserId)
    {
        return success(jobUsersService.selectJobUsersByJobUserId(jobUserId));
    }

    /**
     * 新增就业信息
     */
    @PreAuthorize("@ss.hasPermi('job_users:job_users:add')")
    @Log(title = "就业信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody JobUsers jobUsers)
    {
        SysUser user= SecurityUtils.getLoginUser().getUser();
        jobUsers.setDeptId(105L);
        jobUsers.setUserId(user.getUserId());
        return toAjax(jobUsersService.insertJobUsers(jobUsers));
    }

    /**
     * 修改就业信息
     */
    @PreAuthorize("@ss.hasPermi('job_users:job_users:edit')")
    @Log(title = "就业信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody JobUsers jobUsers)
    {
        return toAjax(jobUsersService.updateJobUsers(jobUsers));
    }

    /**
     * 删除就业信息
     */
    @PreAuthorize("@ss.hasPermi('job_users:job_users:remove')")
    @Log(title = "就业信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{jobUserIds}")
    public AjaxResult remove(@PathVariable Long[] jobUserIds)
    {
        return toAjax(jobUsersService.deleteJobUsersByJobUserIds(jobUserIds));
    }
}
